Pandas Filtering Data

In [2]:

import pandas as pdhouses = pd.read_csv("data/kc_house_data.csv")titanic = pd.read_csv("data/titanic.csv")netflix = pd.read_csv("data/netflix_titles.csv", sep="|", index_col=0)

In [78]:

df = titanic.head()df.sex

Out[78]:

0    female

1      male

2    female

3      male

4    female

Name: sex, dtype: object

In [79]:

df.sex == 'female'

Out[79]:

0     True

1    False

2     True

3    False

4     True

Name: sex, dtype: bool

In [81]:

df[df.sex == 'female']

Out[81]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

0

1

1

Allen, Miss. Elisabeth Walton

female

29

0

0

24160

211.3375

B5

S

2

?

St Louis, MO

2

1

0

Allison, Miss. Helen Loraine

female

2

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

4

1

0

Allison, Mrs. Hudson J C (Bessie Waldo Daniels)

female

25

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

In [82]:

df

Out[82]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

0

1

1

Allen, Miss. Elisabeth Walton

female

29

0

0

24160

211.3375

B5

S

2

?

St Louis, MO

1

1

1

Allison, Master. Hudson Trevor

male

0.9167

1

2

113781

151.55

C22 C26

S

11

?

Montreal, PQ / Chesterville, ON

2

1

0

Allison, Miss. Helen Loraine

female

2

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

3

1

0

Allison, Mr. Hudson Joshua Creighton

male

30

1

2

113781

151.55

C22 C26

S

?

135

Montreal, PQ / Chesterville, ON

4

1

0

Allison, Mrs. Hudson J C (Bessie Waldo Daniels)

female

25

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

In [85]:

df[df["survived"] == 0]

Out[85]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

2

1

0

Allison, Miss. Helen Loraine

female

2

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

3

1

0

Allison, Mr. Hudson Joshua Creighton

male

30

1

2

113781

151.55

C22 C26

S

?

135

Montreal, PQ / Chesterville, ON

4

1

0

Allison, Mrs. Hudson J C (Bessie Waldo Daniels)

female

25

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

In [87]:

bools = [True, False, True, True, True]df[bools]

Out[87]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

0

1

1

Allen, Miss. Elisabeth Walton

female

29

0

0

24160

211.3375

B5

S

2

?

St Louis, MO

2

1

0

Allison, Miss. Helen Loraine

female

2

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

3

1

0

Allison, Mr. Hudson Joshua Creighton

male

30

1

2

113781

151.55

C22 C26

S

?

135

Montreal, PQ / Chesterville, ON

4

1

0

Allison, Mrs. Hudson J C (Bessie Waldo Daniels)

female

25

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

In [90]:

titanic[titanic.survived == 1]

Out[90]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

0

1

1

Allen, Miss. Elisabeth Walton

female

29

0

0

24160

211.3375

B5

S

2

?

St Louis, MO

1

1

1

Allison, Master. Hudson Trevor

male

0.9167

1

2

113781

151.55

C22 C26

S

11

?

Montreal, PQ / Chesterville, ON

5

1

1

Anderson, Mr. Harry

male

48

0

0

19952

26.55

E12

S

3

?

New York, NY

6

1

1

Andrews, Miss. Kornelia Theodosia

female

63

1

0

13502

77.9583

D7

S

10

?

Hudson, NY

8

1

1

Appleton, Mrs. Edward Dale (Charlotte Lamson)

female

53

2

0

11769

51.4792

C101

S

D

?

Bayside, Queens, NY

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

1261

3

1

Turkula, Mrs. (Hedwig)

female

63

0

0

4134

9.5875

?

S

15

?

?

1277

3

1

Vartanian, Mr. David

male

22

0

0

2658

7.225

?

C

13 15

?

?

1286

3

1

Whabee, Mrs. George Joseph (Shawneene Abi-Saab)

female

38

0

0

2688

7.2292

?

C

C

?

?

1290

3

1

Wilkes, Mrs. James (Ellen Needs)

female

47

1

0

363272

7

?

S

?

?

?

1300

3

1

Yasbeck, Mrs. Antoni (Selini Alexander)

female

15

1

0

2659

14.4542

?

C

?

?

?

500 rows × 14 columns

In [96]:

titanic[titanic.age == "18"]

Out[96]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

11

1

1

Astor, Mrs. John Jacob (Madeleine Talmadge Force)

female

18

1

0

PC 17757

227.525

C62 C64

C

4

?

New York, NY

198

1

1

Marvin, Mrs. Daniel Warner (Mary Graham Carmic...

female

18

1

0

113773

53.1

D30

S

10

?

New York, NY

228

1

0

Penasco y Castellana, Mr. Victor de Satode

male

18

1

0

PC 17758

108.9

C65

C

?

?

Madrid, Spain

250

1

1

Ryerson, Miss. Emily Borie

female

18

2

2

PC 17608

262.375

B57 B59 B63 B66

C

4

?

Haverford, PA / Cooperstown, NY

270

1

1

Smith, Mrs. Lucien Philip (Mary Eloise Hughes)

female

18

1

0

13695

60

C31

S

6

?

Huntington, WV

289

1

1

Taussig, Miss. Ruth

female

18

0

2

110413

79.65

E68

S

8

?

New York, NY

326

2

0

Andrew, Mr. Edgardo Samuel

male

18

0

0

231945

11.5

?

S

?

?

Buenos Aires, Argentina / New Jersey, NJ

331

2

0

Bailey, Mr. Percy Andrew

male

18

0

0

29108

11.5

?

S

?

?

Penzance, Cornwall / Akron, OH

386

2

0

Davies, Mr. Charles Henry

male

18

0

0

S.O.C. 14879

73.5

?

S

?

?

Lyndhurst, England

394

2

0

Dibden, Mr. William

male

18

0

0

S.O.C. 14879

73.5

?

S

?

?

New Forest, England

395

2

1

Doling, Miss. Elsie

female

18

0

1

231919

23

?

S

?

?

Southampton

405

2

0

Fahlstrom, Mr. Arne Jonas

male

18

0

0

236171

13

?

S

?

?

Oslo, Norway Bayonne, NJ

408

2

0

Fillbrook, Mr. Joseph Charles

male

18

0

0

C.A. 15185

10.5

?

S

?

?

Cornwall / Houghton, MI

445

2

0

Hiltunen, Miss. Marta

female

18

1

1

250650

13

?

S

?

?

Kontiolahti, Finland / Detroit, MI

558

2

1

Silven, Miss. Lyyli Karoliina

female

18

0

2

250652

13

?

S

16

?

Finland / Minneapolis, MN

607

3

1

Abrahim, Mrs. Joseph (Sophie Halaut Easu)

female

18

0

0

2657

7.2292

?

C

C

?

Greensburg, PA

612

3

1

Aks, Mrs. Sam (Leah Rosen)

female

18

0

1

392091

9.35

?

S

13

?

London, England Norfolk, VA

619

3

0

Allum, Mr. Owen George

male

18

0

0

2223

8.3

?

S

?

259

Windsor, England New York, NY

636

3

0

Arnold-Franchi, Mrs. Josef (Josefine Franchi)

female

18

1

0

349237

17.8

?

S

?

?

Altdorf, Switzerland

661

3

1

Badman, Miss. Emily Louisa

female

18

0

0

A/4 31416

8.05

?

S

C

?

London Skanteales, NY

665

3

0

Barbara, Miss. Saiide

female

18

0

1

2691

14.4542

?

C

?

?

Syria Ottawa, ON

676

3

0

Bjorklund, Mr. Ernst Herbert

male

18

0

0

347090

7.75

?

S

?

?

Stockholm, Sweden New York

695

3

0

Burns, Miss. Mary Delia

female

18

0

0

330963

7.8792

?

Q

?

?

Co Sligo, Ireland New York, NY

698

3

0

Cacic, Mr. Jego Grga

male

18

0

0

315091

8.6625

?

S

?

?

?

717

3

0

Chronopoulos, Mr. Demetrios

male

18

1

0

2680

14.4542

?

C

?

?

Greece

719

3

1

Cohen, Mr. Gurshon 'Gus'

male

18

0

0

A/5 3540

8.05

?

S

12

?

London Brooklyn, NY

786

3

0

Edvardsson, Mr. Gustaf Hjalmar

male

18

0

0

349912

7.775

?

S

?

?

Tofta, Sweden Joliet, IL

799

3

0

Fischer, Mr. Eberhard Thelander

male

18

0

0

350036

7.7958

?

S

?

?

?

809

3

0

Ford, Mr. Edward Watson

male

18

2

2

W./C. 6608

34.375

?

S

?

?

Rotherfield, Sussex, England Essex Co, MA

859

3

0

Hegarty, Miss. Hanora 'Nora'

female

18

0

0

365226

6.75

?

Q

?

?

?

938

3

0

Klasen, Mr. Klas Albin

male

18

1

1

350404

7.8542

?

S

?

?

?

1045

3

0

Myhrman, Mr. Pehr Fabian Oliver Malkolm

male

18

0

0

347078

7.75

?

S

?

?

?

1060

3

1

Nilsson, Miss. Berta Olivia

female

18

0

0

347066

7.775

?

S

D

?

?

1130

3

0

Pettersson, Miss. Ellen Natalia

female

18

0

0

347087

7.775

?

S

?

?

?

1157

3

0

Rosblom, Mr. Viktor Richard

male

18

1

1

370129

20.2125

?

S

?

?

?

1205

3

1

Sjoblom, Miss. Anna Sofia

female

18

0

0

3101265

7.4958

?

S

16

?

?

1260

3

1

Turja, Miss. Anna Sofia

female

18

0

0

4138

9.8417

?

S

15

?

?

1273

3

0

Vander Planke, Miss. Augusta Maria

female

18

2

0

345764

18

?

S

?

?

?

1288

3

0

Wiklund, Mr. Jakob Alfred

male

18

1

0

3101267

6.4958

?

S

?

314

?

In [105]:

titanic[titanic.pclass != 1]

Out[105]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

323

2

0

Abelson, Mr. Samuel

male

30

1

0

P/PP 3381

24

?

C

?

?

Russia New York, NY

324

2

1

Abelson, Mrs. Samuel (Hannah Wizosky)

female

28

1

0

P/PP 3381

24

?

C

10

?

Russia New York, NY

325

2

0

Aldworth, Mr. Charles Augustus

male

30

0

0

248744

13

?

S

?

?

Bryn Mawr, PA, USA

326

2

0

Andrew, Mr. Edgardo Samuel

male

18

0

0

231945

11.5

?

S

?

?

Buenos Aires, Argentina / New Jersey, NJ

327

2

0

Andrew, Mr. Frank Thomas

male

25

0

0

C.A. 34050

10.5

?

S

?

?

Cornwall, England Houghton, MI

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

1304

3

0

Zabour, Miss. Hileni

female

14.5

1

0

2665

14.4542

?

C

?

328

?

1305

3

0

Zabour, Miss. Thamine

female

?

1

0

2665

14.4542

?

C

?

?

?

1306

3

0

Zakarian, Mr. Mapriededer

male

26.5

0

0

2656

7.225

?

C

?

304

?

1307

3

0

Zakarian, Mr. Ortin

male

27

0

0

2670

7.225

?

C

?

?

?

1308

3

0

Zimmerman, Mr. Leo

male

29

0

0

315082

7.875

?

S

?

?

?

986 rows × 14 columns

In [108]:

houses[houses["price"] > 5000000]

Out[108]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

1164

1247600105

20141020T000000

5110800.0

5

5.25

8010

45517

2.0

1

4

...

12

5990

2020

1999

0

98033

47.6767

-122.211

3430

26788

1315

7558700030

20150413T000000

5300000.0

6

6.00

7390

24829

2.0

1

4

...

12

5000

2390

1991

0

98040

47.5631

-122.210

4320

24619

1448

8907500070

20150413T000000

5350000.0

5

5.00

8000

23985

2.0

0

4

...

12

6720

1280

2009

0

98004

47.6232

-122.220

4600

21750

3914

9808700762

20140611T000000

7062500.0

5

4.50

10040

37325

2.0

1

2

...

11

7680

2360

1940

2001

98004

47.6500

-122.214

3930

25449

4411

2470100110

20140804T000000

5570000.0

5

5.75

9200

35069

2.0

0

0

...

13

6200

3000

2001

0

98039

47.6289

-122.233

3560

24345

7252

6762700020

20141013T000000

7700000.0

6

8.00

12050

27600

2.5

0

3

...

13

8570

3480

1910

1987

98102

47.6298

-122.323

3940

8800

9254

9208900037

20140919T000000

6885000.0

6

7.75

9890

31374

2.0

0

4

...

13

8860

1030

2001

0

98039

47.6305

-122.240

4540

42730

7 rows × 21 columns

In [110]:

houses[houses['bedrooms'] > 10]

Out[110]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

8757

1773100755

20140821T000000

520000.0

11

3.00

3000

4960

2.0

0

0

...

7

2400

600

1918

1999

98106

47.5560

-122.363

1420

4960

15870

2402100895

20140625T000000

640000.0

33

1.75

1620

6000

1.0

0

0

...

7

1040

580

1947

0

98103

47.6878

-122.331

1330

4700

2 rows × 21 columns

In [111]:

houses[houses['bedrooms'] >= 10]

Out[111]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

8757

1773100755

20140821T000000

520000.0

11

3.00

3000

4960

2.0

0

0

...

7

2400

600

1918

1999

98106

47.5560

-122.363

1420

4960

13314

627300145

20140814T000000

1148000.0

10

5.25

4590

10920

1.0

0

2

...

9

2500

2090

2008

0

98004

47.5861

-122.113

2730

10400

15161

5566100170

20141029T000000

650000.0

10

2.00

3610

11914

2.0

0

0

...

7

3010

600

1958

0

98006

47.5705

-122.175

2040

11914

15870

2402100895

20140625T000000

640000.0

33

1.75

1620

6000

1.0

0

0

...

7

1040

580

1947

0

98103

47.6878

-122.331

1330

4700

19254

8812401450

20141229T000000

660000.0

10

3.00

2920

3745

2.0

0

0

...

7

1860

1060

1913

0

98105

47.6635

-122.320

1810

3745

5 rows × 21 columns

In [113]:

houses[houses["sqft_living"] < 500]

Out[113]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

465

8658300340

20140523T000000

80000.0

1

0.75

430

5050

1.0

0

0

...

4

430

0

1912

0

98014

47.6499

-121.909

1200

7500

860

1723049033

20140620T000000

245000.0

1

0.75

380

15000

1.0

0

0

...

5

380

0

1963

0

98168

47.4810

-122.323

1170

15000

1168

3523029041

20141009T000000

290000.0

2

0.75

440

8313

1.0

1

3

...

5

440

0

1943

0

98070

47.4339

-122.512

880

26289

4203

1437500015

20140709T000000

150000.0

3

0.75

490

38500

1.5

0

0

...

5

490

0

1959

0

98014

47.7112

-121.315

800

18297

4868

6896300380

20141002T000000

228000.0

0

1.00

390

5900

1.0

0

0

...

4

390

0

1953

0

98118

47.5260

-122.261

2170

6000

8133

7849202585

20140904T000000

170000.0

1

1.00

480

4560

1.0

0

0

...

5

480

0

1922

0

98065

47.5253

-121.826

890

4803

8623

6303400395

20150130T000000

325000.0

1

0.75

410

8636

1.0

0

0

...

4

410

0

1953

0

98146

47.5077

-122.357

1190

8636

11500

4322200105

20150331T000000

229050.0

1

1.00

420

3298

1.0

0

0

...

4

420

0

1949

0

98136

47.5375

-122.391

1460

4975

12075

8655900162

20150219T000000

156000.0

1

0.75

470

15000

1.0

0

0

...

4

470

0

1947

0

98014

47.6554

-121.908

1730

22500

14466

7549801385

20140612T000000

280000.0

1

0.75

420

6720

1.0

0

0

...

5

420

0

1922

0

98108

47.5520

-122.311

1420

6720

15248

1320069249

20141020T000000

192500.0

1

1.00

470

63737

1.0

0

2

...

5

470

0

1924

0

98022

47.2163

-121.984

1350

46762

15381

2856101479

20140701T000000

276000.0

1

0.75

370

1801

1.0

0

0

...

5

370

0

1923

0

98117

47.6778

-122.389

1340

5000

17394

745000005

20140825T000000

145000.0

1

0.75

480

9750

1.0

0

0

...

4

480

0

1948

0

98146

47.4982

-122.362

1550

9924

18052

1352300580

20141114T000000

247000.0

1

1.00

460

4120

1.0

0

0

...

4

460

0

1937

0

98055

47.4868

-122.199

990

4120

18379

1222029077

20141029T000000

265000.0

0

0.75

384

213444

1.0

0

0

...

4

384

0

2003

0

98070

47.4177

-122.491

1920

224341

19452

3980300371

20140926T000000

142000.0

0

0.00

290

20875

1.0

0

0

...

1

290

0

1963

0

98024

47.5308

-121.888

1620

22850

21332

9266700190

20150511T000000

245000.0

1

1.00

390

2000

1.0

0

0

...

6

390

0

1920

0

98103

47.6938

-122.347

1340

5100

17 rows × 21 columns

In [114]:

houses[houses["sqft_living"] <= 500]

Out[114]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

465

8658300340

20140523T000000

80000.0

1

0.75

430

5050

1.0

0

0

...

4

430

0

1912

0

98014

47.6499

-121.909

1200

7500

860

1723049033

20140620T000000

245000.0

1

0.75

380

15000

1.0

0

0

...

5

380

0

1963

0

98168

47.4810

-122.323

1170

15000

1168

3523029041

20141009T000000

290000.0

2

0.75

440

8313

1.0

1

3

...

5

440

0

1943

0

98070

47.4339

-122.512

880

26289

4203

1437500015

20140709T000000

150000.0

3

0.75

490

38500

1.5

0

0

...

5

490

0

1959

0

98014

47.7112

-121.315

800

18297

4651

859000110

20141002T000000

125000.0

1

1.00

500

7440

1.0

0

0

...

5

500

0

1928

0

98106

47.5252

-122.362

1350

7440

4868

6896300380

20141002T000000

228000.0

0

1.00

390

5900

1.0

0

0

...

4

390

0

1953

0

98118

47.5260

-122.261

2170

6000

8133

7849202585

20140904T000000

170000.0

1

1.00

480

4560

1.0

0

0

...

5

480

0

1922

0

98065

47.5253

-121.826

890

4803

8623

6303400395

20150130T000000

325000.0

1

0.75

410

8636

1.0

0

0

...

4

410

0

1953

0

98146

47.5077

-122.357

1190

8636

11500

4322200105

20150331T000000

229050.0

1

1.00

420

3298

1.0

0

0

...

4

420

0

1949

0

98136

47.5375

-122.391

1460

4975

12075

8655900162

20150219T000000

156000.0

1

0.75

470

15000

1.0

0

0

...

4

470

0

1947

0

98014

47.6554

-121.908

1730

22500

14466

7549801385

20140612T000000

280000.0

1

0.75

420

6720

1.0

0

0

...

5

420

0

1922

0

98108

47.5520

-122.311

1420

6720

15248

1320069249

20141020T000000

192500.0

1

1.00

470

63737

1.0

0

2

...

5

470

0

1924

0

98022

47.2163

-121.984

1350

46762

15381

2856101479

20140701T000000

276000.0

1

0.75

370

1801

1.0

0

0

...

5

370

0

1923

0

98117

47.6778

-122.389

1340

5000

17394

745000005

20140825T000000

145000.0

1

0.75

480

9750

1.0

0

0

...

4

480

0

1948

0

98146

47.4982

-122.362

1550

9924

18052

1352300580

20141114T000000

247000.0

1

1.00

460

4120

1.0

0

0

...

4

460

0

1937

0

98055

47.4868

-122.199

990

4120

18379

1222029077

20141029T000000

265000.0

0

0.75

384

213444

1.0

0

0

...

4

384

0

2003

0

98070

47.4177

-122.491

1920

224341

19452

3980300371

20140926T000000

142000.0

0

0.00

290

20875

1.0

0

0

...

1

290

0

1963

0

98024

47.5308

-121.888

1620

22850

21332

9266700190

20150511T000000

245000.0

1

1.00

390

2000

1.0

0

0

...

6

390

0

1920

0

98103

47.6938

-122.347

1340

5100

18 rows × 21 columns

In [133]:

houses[houses["bedrooms"].between(5, 7)]

Out[133]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

14

1175000570

20150312T000000

530000.0

5

2.00

1810

4850

1.5

0

0

...

7

1810

0

1900

0

98107

47.6700

-122.394

1360

4850

22

7137970340

20140703T000000

285000.0

5

2.50

2270

6300

2.0

0

0

...

8

2270

0

1995

0

98092

47.3266

-122.169

2240

7005

42

7203220400

20140707T000000

861990.0

5

2.75

3595

5639

2.0

0

0

...

9

3595

0

2014

0

98053

47.6848

-122.016

3625

5639

51

7231300125

20150217T000000

345000.0

5

2.50

3150

9134

1.0

0

0

...

8

1640

1510

1966

0

98056

47.4934

-122.189

1990

9133

54

4217401195

20150303T000000

920000.0

5

2.25

2730

6000

1.5

0

0

...

8

2130

600

1927

0

98105

47.6571

-122.281

2730

6000

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

21564

7168100015

20141009T000000

579950.0

5

2.75

3080

5752

2.0

0

0

...

9

3080

0

2014

0

98059

47.4922

-122.153

3000

4650

21576

9253900271

20150107T000000

3567000.0

5

4.50

4850

10584

2.0

1

4

...

10

3540

1310

2007

0

98008

47.5943

-122.110

3470

18270

21593

8672200110

20150317T000000

1088000.0

5

3.75

4170

8142

2.0

0

2

...

10

4170

0

2006

0

98056

47.5354

-122.181

3030

7980

21596

7502800100

20140813T000000

679950.0

5

2.75

3600

9437

2.0

0

0

...

9

3600

0

2014

0

98059

47.4822

-122.131

3550

9421

21600

249000205

20141015T000000

1537000.0

5

3.75

4470

8088

2.0

0

0

...

11

4470

0

2008

0

98004

47.6321

-122.200

2780

8964

1911 rows × 21 columns

In [134]:

houses[houses["grade"].between(11,13)]

Out[134]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

5

7237550310

20140512T000000

1225000.0

4

4.50

5420

101930

1.0

0

0

...

11

3890

1530

2001

0

98053

47.6561

-122.005

4760

101930

70

1525059190

20140912T000000

1040000.0

5

3.25

4770

50094

1.0

0

0

...

11

3070

1700

1973

0

98005

47.6525

-122.160

3530

38917

153

7855801670

20150401T000000

2250000.0

4

3.25

5180

19850

2.0

0

3

...

12

3540

1640

2006

0

98006

47.5620

-122.162

3160

9750

269

7960900060

20150504T000000

2900000.0

4

3.25

5050

20100

1.5

0

2

...

11

4750

300

1982

2008

98004

47.6312

-122.223

3890

20060

270

4054500390

20141007T000000

1365000.0

4

4.75

5310

57346

2.0

0

0

...

11

5310

0

1989

0

98077

47.7285

-122.042

4180

47443

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

21532

324069112

20140617T000000

1325000.0

4

4.00

4420

16526

2.0

0

0

...

11

4420

0

2013

0

98075

47.5914

-122.027

3510

50447

21548

8835770330

20140819T000000

1057000.0

2

1.50

2370

184231

2.0

0

0

...

11

2370

0

2005

0

98045

47.4543

-121.778

3860

151081

21551

1561750040

20141224T000000

1375000.0

5

4.50

4350

13405

2.0

0

0

...

11

4350

0

2014

0

98074

47.6018

-122.060

3990

7208

21590

7430200100

20140514T000000

1222500.0

4

3.50

4910

9444

1.5

0

0

...

11

3110

1800

2007

0

98074

47.6502

-122.066

4560

11063

21600

249000205

20141015T000000

1537000.0

5

3.75

4470

8088

2.0

0

0

...

11

4470

0

2008

0

98004

47.6321

-122.200

2780

8964

502 rows × 21 columns

In [142]:

countries = ["India", "Japan", "South Korea"]netflix[netflix["country"].isin(countries)]

Out[142]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

4

s5

TV Show

Kota Factory

NaN

Mayur More, Jitendra Kumar, Ranjan Raj, Alam K...

India

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, Romantic TV Shows, TV ...

In a city of coaching centers known to train I...

24

s25

Movie

Jeans

S. Shankar

Prashanth, Aishwarya Rai Bachchan, Sri Lakshmi...

India

September 21, 2021

1998

TV-14

166 min

Comedies, International Movies, Romantic Movies

When the father of the man she loves insists t...

39

s40

TV Show

Chhota Bheem

NaN

Vatsal Dubey, Julie Tejwani, Rupa Bhimani, Jig...

India

September 16, 2021

2021

TV-Y7

3 Seasons

Kids' TV

A brave, energetic little boy with superhuman ...

50

s51

TV Show

Dharmakshetra

NaN

Kashmira Irani, Chandan Anand, Dinesh Mehta, A...

India

September 15, 2021

2014

TV-PG

1 Season

International TV Shows, TV Dramas, TV Sci-Fi &...

After the ancient Great War, the god Chitragup...

51

s52

Movie

InuYasha the Movie 2: The Castle Beyond the Lo...

Toshiya Shinohara

Kappei Yamaguchi, Satsuki Yukino, Mieko Harada...

Japan

September 15, 2021

2002

TV-14

99 min

Action & Adventure, Anime Features, Internatio...

With their biggest foe seemingly defeated, Inu...

...

...

...

...

...

...

...

...

...

...

...

...

...

8773

s8774

Movie

Yanda Kartavya Aahe

Kedar Shinde

Ankush Choudhary, Smita Shewale, Mohan Joshi, ...

India

January 1, 2018

2006

TV-PG

151 min

Comedies, Dramas, International Movies

Thanks to an arranged marriage that was design...

8775

s8776

TV Show

Yeh Meri Family

NaN

Vishesh Bansal, Mona Singh, Akarsh Khurana, Ah...

India

August 31, 2018

2018

TV-PG

1 Season

International TV Shows, TV Comedies

In the summer of 1998, middle child Harshu bal...

8798

s8799

Movie

Zed Plus

Chandra Prakash Dwivedi

Adil Hussain, Mona Singh, K.K. Raina, Sanjay M...

India

December 31, 2019

2014

TV-MA

131 min

Comedies, Dramas, International Movies

A philandering small-town mechanic's political...

8799

s8800

Movie

Zenda

Avadhoot Gupte

Santosh Juvekar, Siddharth Chandekar, Sachit P...

India

February 15, 2018

2009

TV-14

120 min

Dramas, International Movies

A change in the leadership of a political part...

8806

s8807

Movie

Zubaan

Mozez Singh

Vicky Kaushal, Sarah-Jane Dias, Raaghav Chanan...

India

March 2, 2019

2015

TV-14

111 min

Dramas, International Movies, Music & Musicals

A scrappy but poor boy worms his way into a ty...

1416 rows × 12 columns

In [146]:

mature = netflix["rating"].isin(["TV-MA", "R", "PG-13"])netflix[mature]

Out[146]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

0

s1

Movie

Dick Johnson Is Dead

Kirsten Johnson

NaN

United States

September 25, 2021

2020

PG-13

90 min

Documentaries

As her father nears the end of his life, filmm...

1

s2

TV Show

Blood & Water

NaN

Ama Qamata, Khosi Ngema, Gail Mabalane, Thaban...

South Africa

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, TV Dramas, TV Mysteries

After crossing paths at a party, a Cape Town t...

2

s3

TV Show

Ganglands

Julien Leclercq

Sami Bouajila, Tracy Gotoas, Samuel Jouy, Nabi...

NaN

September 24, 2021

2021

TV-MA

1 Season

Crime TV Shows, International TV Shows, TV Act...

To protect his family from a powerful drug lor...

3

s4

TV Show

Jailbirds New Orleans

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Docuseries, Reality TV

Feuds, flirtations and toilet talk go down amo...

4

s5

TV Show

Kota Factory

NaN

Mayur More, Jitendra Kumar, Ranjan Raj, Alam K...

India

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, Romantic TV Shows, TV ...

In a city of coaching centers known to train I...

...

...

...

...

...

...

...

...

...

...

...

...

...

8791

s8792

Movie

Young Adult

Jason Reitman

Charlize Theron, Patton Oswalt, Patrick Wilson...

United States

November 20, 2019

2011

R

94 min

Comedies, Dramas, Independent Movies

When a divorced writer gets a letter from an o...

8798

s8799

Movie

Zed Plus

Chandra Prakash Dwivedi

Adil Hussain, Mona Singh, K.K. Raina, Sanjay M...

India

December 31, 2019

2014

TV-MA

131 min

Comedies, Dramas, International Movies

A philandering small-town mechanic's political...

8801

s8802

Movie

Zinzana

Majid Al Ansari

Ali Suliman, Saleh Bakri, Yasa, Ali Al-Jabri, ...

United Arab Emirates, Jordan

March 9, 2016

2015

TV-MA

96 min

Dramas, International Movies, Thrillers

Recovering alcoholic Talal wakes up inside a s...

8802

s8803

Movie

Zodiac

David Fincher

Mark Ruffalo, Jake Gyllenhaal, Robert Downey J...

United States

November 20, 2019

2007

R

158 min

Cult Movies, Dramas, Thrillers

A political cartoonist, a crime reporter and a...

8804

s8805

Movie

Zombieland

Ruben Fleischer

Jesse Eisenberg, Woody Harrelson, Emma Stone, ...

United States

November 1, 2019

2009

R

88 min

Comedies, Horror Movies

Looking to survive in a world taken over by zo...

4496 rows × 12 columns

In [155]:

women = titanic.sex == 'female'died = titanic.survived == 0titanic[women & died]

Out[155]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

2

1

0

Allison, Miss. Helen Loraine

female

2

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

4

1

0

Allison, Mrs. Hudson J C (Bessie Waldo Daniels)

female

25

1

2

113781

151.55

C22 C26

S

?

?

Montreal, PQ / Chesterville, ON

105

1

0

Evans, Miss. Edith Corse

female

36

0

0

PC 17531

31.6792

A29

C

?

?

New York, NY

169

1

0

Isham, Miss. Ann Elizabeth

female

50

0

0

PC 17595

28.7125

C49

C

?

?

Paris, France New York, NY

286

1

0

Straus, Mrs. Isidor (Rosalie Ida Blun)

female

63

1

0

PC 17483

221.7792

C55 C57

S

?

?

New York, NY

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

1273

3

0

Vander Planke, Miss. Augusta Maria

female

18

2

0

345764

18

?

S

?

?

?

1276

3

0

Vander Planke, Mrs. Julius (Emelia Maria Vande...

female

31

1

0

345763

18

?

S

?

?

?

1279

3

0

Vestrom, Miss. Hulda Amanda Adolfina

female

14

0

0

350406

7.8542

?

S

?

?

?

1304

3

0

Zabour, Miss. Hileni

female

14.5

1

0

2665

14.4542

?

C

?

328

?

1305

3

0

Zabour, Miss. Thamine

female

?

1

0

2665

14.4542

?

C

?

?

?

127 rows × 14 columns

In [160]:

houses[(houses["waterfront"] == 1) & (houses["price"] < 500000)]

Out[160]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

264

2123039032

20141027T000000

369900.0

1

0.75

760

10079

1.0

1

4

...

5

760

0

1936

0

98070

47.4683

-122.438

1230

14267

1168

3523029041

20141009T000000

290000.0

2

0.75

440

8313

1.0

1

3

...

5

440

0

1943

0

98070

47.4339

-122.512

880

26289

1949

1922039062

20150420T000000

480000.0

2

1.50

1008

26487

1.0

1

4

...

6

1008

0

1943

2002

98070

47.3853

-122.479

1132

24079

3829

8550001515

20141001T000000

429592.0

2

2.75

1992

10946

1.5

1

4

...

6

1288

704

1903

0

98070

47.3551

-122.475

1110

8328

6102

222029026

20140917T000000

340000.0

2

0.75

1060

48292

1.0

1

2

...

6

560

500

1947

0

98070

47.4285

-122.511

750

80201

8277

221029019

20150428T000000

400000.0

3

2.50

2090

32718

2.0

1

4

...

7

1550

540

1919

1983

98070

47.3338

-122.511

1200

192268

8450

121039042

20150313T000000

425000.0

3

2.75

3610

107386

1.5

1

3

...

8

3130

480

1918

1962

98023

47.3351

-122.362

2630

42126

11556

2013802030

20140911T000000

357000.0

3

2.00

2460

53882

1.0

1

4

...

7

2460

0

1955

0

98198

47.3811

-122.325

2660

32625

14827

2423029009

20140617T000000

465000.0

2

2.00

1494

19271

2.0

1

4

...

7

1494

0

1943

1997

98070

47.4728

-122.497

1494

43583

16570

2923039243

20141113T000000

340000.0

4

1.00

1200

11834

1.0

1

3

...

6

1200

0

1972

0

98070

47.4557

-122.443

1670

47462

18275

2781600195

20141117T000000

285000.0

1

1.00

1060

54846

1.0

1

4

...

5

1060

0

1935

0

98070

47.4716

-122.445

2258

31762

18848

7631800110

20140918T000000

380000.0

3

2.50

1980

17342

2.0

1

4

...

10

1580

400

1984

0

98166

47.4551

-122.373

2060

17313

19002

5216200090

20140616T000000

385000.0

2

1.00

830

26329

1.0

1

3

...

6

830

0

1928

0

98070

47.4012

-122.425

2030

27338

13 rows × 21 columns

In [169]:

houses[houses["view"]== 4]houses[houses["grade"] >= 11]houses[(houses["grade"] >= 11) & (houses["view"] == 4)]

Out[169]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

540

622049114

20150218T000000

2125000.0

3

2.50

5403

24069

2.0

1

4

...

12

5403

0

1976

0

98166

47.4169

-122.348

3980

104374

1164

1247600105

20141020T000000

5110800.0

5

5.25

8010

45517

2.0

1

4

...

12

5990

2020

1999

0

98033

47.6767

-122.211

3430

26788

1315

7558700030

20150413T000000

5300000.0

6

6.00

7390

24829

2.0

1

4

...

12

5000

2390

1991

0

98040

47.5631

-122.210

4320

24619

1448

8907500070

20150413T000000

5350000.0

5

5.00

8000

23985

2.0

0

4

...

12

6720

1280

2009

0

98004

47.6232

-122.220

4600

21750

2085

8106100105

20141114T000000

3850000.0

4

4.25

5770

21300

2.0

1

4

...

11

5770

0

1980

0

98040

47.5850

-122.222

4620

22748

2444

7524900003

20141210T000000

3278000.0

2

1.75

6840

10000

2.5

1

4

...

11

4350

2490

2001

0

98008

47.6042

-122.112

3120

12300

2626

7738500731

20140815T000000

4500000.0

5

5.50

6640

40014

2.0

1

4

...

12

6350

290

2004

0

98155

47.7493

-122.280

3030

23408

2713

7851980260

20140730T000000

1110000.0

5

3.50

7350

12231

2.0

0

4

...

11

4750

2600

2001

0

98065

47.5373

-121.865

5380

12587

3157

1827200265

20140911T000000

1899000.0

2

2.75

3690

32044

2.0

1

4

...

12

3690

0

1989

0

98166

47.4485

-122.369

2310

26988

3586

9272200090

20150204T000000

1598890.0

4

4.50

3780

6000

2.0

0

4

...

11

2770

1010

1910

1977

98116

47.5922

-122.388

2660

6000

4013

724069059

20140509T000000

2400000.0

3

2.25

3000

11665

1.5

1

4

...

11

3000

0

2001

0

98075

47.5884

-122.086

3000

15959

4190

2303900090

20140729T000000

2880500.0

4

2.50

5760

32033

2.0

0

4

...

12

4390

1370

1994

0

98177

47.7288

-122.370

3420

28475

4406

3505100756

20141106T000000

2050000.0

4

3.00

4280

18834

1.0

0

4

...

11

2180

2100

1971

0

98116

47.5811

-122.400

2490

8858

5749

6744701310

20150415T000000

1850000.0

4

2.50

3830

11972

1.0

1

4

...

11

2370

1460

1981

0

98155

47.7404

-122.284

3080

12297

5850

3585900500

20150402T000000

1525000.0

4

4.25

4720

21000

3.0

0

4

...

11

4720

0

1971

0

98177

47.7591

-122.376

3010

20000

6233

2024069008

20140619T000000

2200000.0

5

4.75

5990

10450

2.0

1

4

...

11

4050

1940

2002

0

98027

47.5554

-122.077

3330

14810

6501

2626069030

20150209T000000

1940000.0

4

5.75

7220

223462

2.0

0

4

...

12

6220

1000

2000

0

98053

47.7097

-122.013

2680

7593

6508

4217402115

20150421T000000

3650000.0

6

4.75

5480

19401

1.5

1

4

...

11

3910

1570

1936

0

98105

47.6515

-122.277

3510

15810

7269

4139470010

20141006T000000

1615000.0

4

3.25

4250

12281

2.0

0

4

...

12

3020

1230

1996

0

98006

47.5507

-122.113

4940

12941

7313

4131900066

20140825T000000

3100000.0

3

3.00

3920

13085

2.0

1

4

...

11

3920

0

1996

0

98040

47.5716

-122.204

3450

13287

7700

3761700053

20150105T000000

2150000.0

3

2.75

3470

9610

3.0

1

4

...

11

3470

0

1989

2000

98034

47.7205

-122.260

4130

11875

8092

1924059029

20140617T000000

4668000.0

5

6.75

9640

13068

1.0

1

4

...

12

4820

4820

1983

2009

98040

47.5570

-122.210

3270

10454

8174

9279700150

20150212T000000

1625000.0

4

3.75

4410

8112

3.0

0

4

...

11

3570

840

2003

0

98116

47.5888

-122.392

2770

5750

8568

8653600100

20150330T000000

750000.0

5

2.50

3120

15593

2.0

0

4

...

11

3120

0

1986

0

98074

47.6142

-122.065

3390

17003

9254

9208900037

20140919T000000

6885000.0

6

7.75

9890

31374

2.0

0

4

...

13

8860

1030

2001

0

98039

47.6305

-122.240

4540

42730

10385

3225069301

20140612T000000

1228000.0

4

2.50

5730

44947

2.0

0

4

...

11

4280

1450

1991

0

98074

47.6052

-122.064

3310

17628

10465

333100295

20141124T000000

3120000.0

3

3.50

4490

56609

2.0

1

4

...

12

4490

0

1993

0

98034

47.6997

-122.240

2710

51330

10665

7852160310

20140814T000000

1010000.0

4

2.75

3430

15877

1.0

0

4

...

11

3430

0

2005

0

98065

47.5364

-121.856

4080

14577

11402

3426049284

20140819T000000

2300000.0

4

3.25

4110

15929

2.0

1

4

...

12

2720

1390

2001

0

98115

47.6934

-122.271

2640

15929

11535

8964800890

20150109T000000

3200000.0

3

3.25

4560

13363

1.0

0

4

...

11

2760

1800

1995

0

98004

47.6205

-122.214

4060

13362

11729

2303900045

20140623T000000

1580000.0

4

2.50

4570

74487

2.0

0

4

...

12

4570

0

1948

1985

98177

47.7282

-122.372

3810

74487

11829

4139420640

20141030T000000

1785000.0

4

3.50

5490

14300

1.0

0

4

...

12

2910

2580

1996

0

98006

47.5511

-122.114

4290

13822

12429

98001070

20140818T000000

1169000.0

5

4.25

4610

13252

2.0

0

4

...

11

4610

0

2004

0

98075

47.5878

-121.969

4400

15154

12777

1225069038

20140505T000000

2280000.0

7

8.00

13540

307752

3.0

0

4

...

12

9410

4130

1999

0

98053

47.6675

-121.986

4850

217800

12872

2424049029

20140529T000000

3100000.0

6

4.25

6980

15682

3.0

0

4

...

12

5330

1650

1999

0

98040

47.5552

-122.231

3930

18367

13068

7856410411

20140922T000000

1698890.0

4

4.50

3860

15246

2.0

0

4

...

11

2940

920

2004

0

98006

47.5600

-122.161

3750

14790

13528

3025059124

20140828T000000

3168750.0

5

3.50

4330

11979

1.0

0

4

...

12

2090

2240

2008

0

98004

47.6251

-122.218

4320

12000

13710

2923500230

20141216T000000

2600000.0

4

4.50

5270

12195

2.0

1

4

...

11

3400

1870

1979

0

98027

47.5696

-122.090

3390

9905

13770

1795800040

20140903T000000

1350000.0

4

3.25

5370

20388

2.0

0

4

...

11

5370

0

1990

0

98198

47.4050

-122.331

2770

22270

14083

3625059043

20140904T000000

3300000.0

5

4.75

6200

13873

2.0

1

4

...

11

4440

1760

1989

0

98008

47.6050

-122.112

2940

13525

14556

2303900035

20140611T000000

2888000.0

5

6.25

8670

64033

2.0

0

4

...

13

6120

2550

1965

2003

98177

47.7295

-122.372

4140

81021

14774

9412400220

20140710T000000

1612500.0

4

2.75

5470

18200

2.0

1

4

...

11

3730

1740

1992

0

98118

47.5316

-122.263

3620

15100

15255

2425049063

20140911T000000

3640900.0

4

3.25

4830

22257

2.0

1

4

...

11

4830

0

1990

0

98039

47.6409

-122.241

3820

25582

15258

1732800780

20150212T000000

3065000.0

5

3.00

4150

7500

2.5

0

4

...

11

3510

640

1909

0

98119

47.6303

-122.362

2250

4050

15482

624069108

20140812T000000

3200000.0

4

3.25

7000

28206

1.0

1

4

...

12

3500

3500

1991

0

98075

47.5928

-122.086

4913

14663

15668

4030100290

20141001T000000

1680000.0

5

3.50

5170

7197

3.0

1

4

...

11

3520

1650

1998

0

98155

47.7561

-122.271

3020

12880

15692

6117502230

20141201T000000

1637500.0

3

3.50

4660

21164

2.0

1

4

...

12

4660

0

1975

1990

98166

47.4418

-122.354

3140

24274

15828

4139420190

20150512T000000

2480000.0

4

5.00

5310

16909

1.0

0

4

...

12

3090

2220

1992

0

98006

47.5515

-122.113

5220

15701

16260

8965510190

20140610T000000

1250000.0

4

2.50

3700

21755

1.0

0

4

...

11

2620

1080

1988

0

98006

47.5662

-122.108

3480

13786

16817

825059178

20140923T000000

2574000.0

4

3.75

4475

20424

2.0

1

4

...

12

2659

1816

1999

0

98033

47.6646

-122.208

4340

5250

16837

4441300170

20150112T000000

1300000.0

4

2.50

3110

11857

2.0

0

4

...

11

2040

1070

1990

0

98117

47.6952

-122.402

3110

11570

17558

7631800015

20150407T000000

2510000.0

3

3.25

5480

57990

2.0

1

4

...

11

5480

0

1991

0

98166

47.4558

-122.371

2500

22954

18199

3625059152

20141230T000000

3300000.0

3

3.25

4220

41300

1.0

1

4

...

11

2460

1760

1958

1987

98008

47.6083

-122.110

3810

30401

18455

8043700300

20140608T000000

2700000.0

4

3.25

4420

7850

2.0

1

4

...

11

3150

1270

2001

0

98008

47.5720

-122.102

2760

8525

19017

2303900100

20140911T000000

3800000.0

3

4.25

5510

35000

2.0

0

4

...

13

4910

600

1997

0

98177

47.7296

-122.370

3430

45302

20005

148000475

20140528T000000

1400000.0

4

3.25

4700

9160

1.0

0

4

...

11

2520

2180

2005

0

98116

47.5744

-122.406

2240

8700

20325

518500480

20140811T000000

3000000.0

3

3.50

4410

10756

2.0

1

4

...

11

3430

980

2014

0

98056

47.5283

-122.205

3550

5634

20923

7852070210

20140527T000000

1149000.0

4

3.00

5940

11533

2.0

0

4

...

11

4950

990

2004

0

98065

47.5443

-121.870

4240

12813

21050

2424059170

20150219T000000

900000.0

5

6.00

7120

40806

2.0

0

4

...

12

5480

1640

2007

0

98006

47.5451

-122.114

3440

36859

21201

518500460

20141008T000000

2230000.0

3

3.50

3760

5634

2.0

1

4

...

11

2830

930

2014

0

98056

47.5285

-122.205

3560

5762

60 rows × 21 columns

In [182]:

high_quality = houses["grade"] >= 11good_view = houses["view"] == 4smaller = houses["sqft_living"] <= 3000houses[high_quality & good_view & smaller]

Out[182]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

4013

724069059

20140509T000000

2400000.0

3

2.25

3000

11665

1.5

1

4

...

11

3000

0

2001

0

98075

47.5884

-122.086

3000

15959

1 rows × 21 columns

In [196]:

houses[houses["yr_built"] >= 2014]houses[houses["yr_renovated"] >= 2014]houses[(houses["yr_built"] >= 2014) | (houses["yr_renovated"] >= 2014)]

Out[196]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

42

7203220400

20140707T000000

861990.0

5

2.75

3595

5639

2.0

0

0

...

9

3595

0

2014

0

98053

47.6848

-122.016

3625

5639

63

9528102996

20141207T000000

549000.0

3

1.75

1540

1044

3.0

0

0

...

8

1540

0

2014

0

98115

47.6765

-122.320

1580

3090

133

8929000270

20140512T000000

453246.0

3

2.50

2010

2287

2.0

0

0

...

8

1390

620

2014

0

98029

47.5517

-121.998

1690

1662

139

2767603505

20140507T000000

519950.0

3

2.25

1170

1249

3.0

0

0

...

8

1170

0

2014

0

98107

47.6722

-122.381

1350

1310

211

1025049114

20140717T000000

625504.0

3

2.25

1270

1566

2.0

0

0

...

8

1060

210

2014

0

98105

47.6647

-122.284

1160

1327

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

21598

8956200760

20141013T000000

541800.0

4

2.50

3118

7866

2.0

0

2

...

9

3118

0

2014

0

98001

47.2931

-122.264

2673

6500

21602

844000965

20140626T000000

224000.0

3

1.75

1500

11968

1.0

0

0

...

6

1500

0

2014

0

98010

47.3095

-122.002

1320

11303

21604

9834201367

20150126T000000

429000.0

3

2.00

1490

1126

3.0

0

0

...

8

1490

0

2014

0

98144

47.5699

-122.288

1400

1230

21605

3448900210

20141014T000000

610685.0

4

2.50

2520

6023

2.0

0

0

...

9

2520

0

2014

0

98056

47.5137

-122.167

2520

6023

21609

6600060120

20150223T000000

400000.0

4

2.50

2310

5813

2.0

0

0

...

8

2310

0

2014

0

98146

47.5107

-122.362

1830

7200

704 rows × 21 columns

In [209]:

netflix[netflix["director"] == "David Fincher"]netflix[netflix["director"] == "Martin Scorsese"]netflix[(netflix["director"] == "David Fincher") | (netflix["director"] == "Martin Scorsese")]netflix[netflix["director"].isin(["David Fincher", "Martin Scorsese"])]

Out[209]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

600

s601

Movie

The Game

David Fincher

Michael Douglas, Sean Penn, Deborah Kara Unger...

United States

July 1, 2021

1997

R

129 min

Thrillers

An aloof investment banker's life spirals into...

1358

s1359

Movie

Shutter Island

Martin Scorsese

Leonardo DiCaprio, Mark Ruffalo, Ben Kingsley,...

United States

February 1, 2021

2010

R

139 min

Thrillers

A U.S. marshal's troubling visions compromise ...

1595

s1596

Movie

MANK

David Fincher

Gary Oldman, Amanda Seyfried, Charles Dance, L...

United States

December 4, 2020

2020

R

133 min

Dramas, Independent Movies

1930s Hollywood is reevaluated through the eye...

2632

s2633

Movie

No Direction Home: Bob Dylan

Martin Scorsese

Bob Dylan, Joan Baez, Dave Van Ronk, Peter Yar...

United Kingdom, United States, Japan

April 25, 2020

2005

TV-MA

208 min

Documentaries, Music & Musicals

Featuring rare concert footage and interviews ...

2860

s2861

Movie

Hugo

Martin Scorsese

Ben Kingsley, Sacha Baron Cohen, Asa Butterfie...

United Kingdom, United States, France

March 1, 2020

2011

PG

127 min

Children & Family Movies, Dramas

Living inside a Paris train station, an orphan...

3227

s3228

Movie

The Irishman

Martin Scorsese

Robert De Niro, Al Pacino, Joe Pesci, Harvey K...

United States

November 27, 2019

2019

R

209 min

Dramas

Hit man Frank Sheeran looks back at the secret...

3759

s3760

Movie

Rolling Thunder Revue: A Bob Dylan Story by Ma...

Martin Scorsese

Bob Dylan, Allen Ginsberg, Joan Baez, Patti Sm...

United States

June 12, 2019

2019

TV-MA

142 min

Documentaries, Music & Musicals

In an alchemic mix of fact and fantasy, Martin...

6111

s6112

Movie

Alice Doesn't Live Here Anymore

Martin Scorsese

Ellen Burstyn, Kris Kristofferson, Billy Green...

United States

July 1, 2019

1974

PG

112 min

Classic Movies, Comedies, Dramas

A widowed singer and single mother starts over...

6826

s6827

Movie

Gangs of New York

Martin Scorsese

Leonardo DiCaprio, Daniel Day-Lewis, Cameron D...

United States, Italy

August 20, 2019

2002

R

167 min

Dramas

In the crime-ridden slums of New York in the 1...

6880

s6881

Movie

GoodFellas

Martin Scorsese

Robert De Niro, Ray Liotta, Joe Pesci, Lorrain...

United States

January 1, 2021

1990

R

145 min

Classic Movies, Dramas

Former mobster Henry Hill recounts his colorfu...

7431

s7432

Movie

Mean Streets

Martin Scorsese

Robert De Niro, Harvey Keitel, David Proval, A...

United States

July 1, 2019

1973

R

112 min

Classic Movies, Dramas, Independent Movies

In New York's Little Italy, a low-level hoodlu...

7701

s7702

Movie

Panic Room

David Fincher

Jodie Foster, Forest Whitaker, Dwight Yoakam, ...

United States

August 1, 2019

2002

R

112 min

Thrillers

A woman and her daughter are caught in a game ...

7820

s7821

Movie

Raging Bull

Martin Scorsese

Robert De Niro, Cathy Moriarty, Joe Pesci, Fra...

United States

October 1, 2019

1980

R

129 min

Classic Movies, Dramas, Sports Movies

This gritty biopic of brutal boxer Jake LaMott...

8272

s8273

Movie

The Departed

Martin Scorsese

Leonardo DiCaprio, Matt Damon, Jack Nicholson,...

United States, Hong Kong

January 1, 2021

2006

R

151 min

Dramas, Thrillers

Two rookie Boston cops are sent deep undercove...

8320

s8321

Movie

The Girl with the Dragon Tattoo

David Fincher

Daniel Craig, Rooney Mara, Christopher Plummer...

United States, Sweden, Norway

January 5, 2021

2011

R

158 min

Dramas, Thrillers

When a young computer hacker is tasked with in...

8511

s8512

Movie

The Social Network

David Fincher

Jesse Eisenberg, Andrew Garfield, Justin Timbe...

United States

April 1, 2020

2010

PG-13

121 min

Dramas

Director David Fincher's biographical drama ch...

8735

s8736

Movie

Who's That Knocking at My Door?

Martin Scorsese

Zina Bethune, Harvey Keitel, Anne Collette, Le...

United States

July 1, 2019

1967

R

90 min

Classic Movies, Dramas, Independent Movies

A woman's revelation that she was once raped s...

8802

s8803

Movie

Zodiac

David Fincher

Mark Ruffalo, Jake Gyllenhaal, Robert Downey J...

United States

November 20, 2019

2007

R

158 min

Cult Movies, Dramas, Thrillers

A political cartoonist, a crime reporter and a...

In [213]:

fincher = netflix["director"] == "David Fincher"scorsese = netflix["director"] == "Martin Scorsese"recent = netflix["release_year"] > 2015netflix[(fincher | scorsese) & recent]

Out[213]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

1595

s1596

Movie

MANK

David Fincher

Gary Oldman, Amanda Seyfried, Charles Dance, L...

United States

December 4, 2020

2020

R

133 min

Dramas, Independent Movies

1930s Hollywood is reevaluated through the eye...

3227

s3228

Movie

The Irishman

Martin Scorsese

Robert De Niro, Al Pacino, Joe Pesci, Harvey K...

United States

November 27, 2019

2019

R

209 min

Dramas

Hit man Frank Sheeran looks back at the secret...

3759

s3760

Movie

Rolling Thunder Revue: A Bob Dylan Story by Ma...

Martin Scorsese

Bob Dylan, Allen Ginsberg, Joan Baez, Patti Sm...

United States

June 12, 2019

2019

TV-MA

142 min

Documentaries, Music & Musicals

In an alchemic mix of fact and fantasy, Martin...

In [246]:

df = titanic.head()women = df.sex == 'female'df[~women]

Out[246]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

1

1

1

Allison, Master. Hudson Trevor

male

0.9167

1

2

113781

151.55

C22 C26

S

11

?

Montreal, PQ / Chesterville, ON

3

1

0

Allison, Mr. Hudson Joshua Creighton

male

30

1

2

113781

151.55

C22 C26

S

?

135

Montreal, PQ / Chesterville, ON

In [249]:

newly_built = houses["yr_built"] >= 2014newly_renovated = houses["yr_renovated"] >= 2014recent_homes = newly_built | newly_renovatedhouses[recent_homes]houses[~recent_homes]

Out[249]:

 

id

date

price

bedrooms

bathrooms

sqft_living

sqft_lot

floors

waterfront

view

...

grade

sqft_above

sqft_basement

yr_built

yr_renovated

zipcode

lat

long

sqft_living15

sqft_lot15

0

7129300520

20141013T000000

221900.0

3

1.00

1180

5650

1.0

0

0

...

7

1180

0

1955

0

98178

47.5112

-122.257

1340

5650

1

6414100192

20141209T000000

538000.0

3

2.25

2570

7242

2.0

0

0

...

7

2170

400

1951

1991

98125

47.7210

-122.319

1690

7639

2

5631500400

20150225T000000

180000.0

2

1.00

770

10000

1.0

0

0

...

6

770

0

1933

0

98028

47.7379

-122.233

2720

8062

3

2487200875

20141209T000000

604000.0

4

3.00

1960

5000

1.0

0

0

...

7

1050

910

1965

0

98136

47.5208

-122.393

1360

5000

4

1954400510

20150218T000000

510000.0

3

2.00

1680

8080

1.0

0

0

...

8

1680

0

1987

0

98074

47.6168

-122.045

1800

7503

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

21607

2997800021

20150219T000000

475000.0

3

2.50

1310

1294

2.0

0

0

...

8

1180

130

2008

0

98116

47.5773

-122.409

1330

1265

21608

263000018

20140521T000000

360000.0

3

2.50

1530

1131

3.0

0

0

...

8

1530

0

2009

0

98103

47.6993

-122.346

1530

1509

21610

1523300141

20140623T000000

402101.0

2

0.75

1020

1350

2.0

0

0

...

7

1020

0

2009

0

98144

47.5944

-122.299

1020

2007

21611

291310100

20150116T000000

400000.0

3

2.50

1600

2388

2.0

0

0

...

8

1600

0

2004

0

98027

47.5345

-122.069

1410

1287

21612

1523300157

20141015T000000

325000.0

2

0.75

1020

1076

2.0

0

0

...

7

1020

0

2008

0

98144

47.5941

-122.299

1020

1357

20909 rows × 21 columns

In [258]:

titanic[titanic.survived == 0]titanic[~(titanic.survived == 0)]

Out[258]:

 

pclass

survived

name

sex

age

sibsp

parch

ticket

fare

cabin

embarked

boat

body

home.dest

0

1

1

Allen, Miss. Elisabeth Walton

female

29

0

0

24160

211.3375

B5

S

2

?

St Louis, MO

1

1

1

Allison, Master. Hudson Trevor

male

0.9167

1

2

113781

151.55

C22 C26

S

11

?

Montreal, PQ / Chesterville, ON

5

1

1

Anderson, Mr. Harry

male

48

0

0

19952

26.55

E12

S

3

?

New York, NY

6

1

1

Andrews, Miss. Kornelia Theodosia

female

63

1

0

13502

77.9583

D7

S

10

?

Hudson, NY

8

1

1

Appleton, Mrs. Edward Dale (Charlotte Lamson)

female

53

2

0

11769

51.4792

C101

S

D

?

Bayside, Queens, NY

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

1261

3

1

Turkula, Mrs. (Hedwig)

female

63

0

0

4134

9.5875

?

S

15

?

?

1277

3

1

Vartanian, Mr. David

male

22

0

0

2658

7.225

?

C

13 15

?

?

1286

3

1

Whabee, Mrs. George Joseph (Shawneene Abi-Saab)

female

38

0

0

2688

7.2292

?

C

C

?

?

1290

3

1

Wilkes, Mrs. James (Ellen Needs)

female

47

1

0

363272

7

?

S

?

?

?

1300

3

1

Yasbeck, Mrs. Antoni (Selini Alexander)

female

15

1

0

2659

14.4542

?

C

?

?

?

500 rows × 14 columns

In [260]:

netflix.info()

<class 'pandas.core.frame.DataFrame'>

Int64Index: 8807 entries, 0 to 8806

Data columns (total 12 columns):

 #   Column        Non-Null Count  Dtype

---  ------        --------------  -----

 0   show_id       8807 non-null   object

 1   type          8807 non-null   object

 2   title         8807 non-null   object

 3   director      6173 non-null   object

 4   cast          7982 non-null   object

 5   country       7976 non-null   object

 6   date_added    8797 non-null   object

 7   release_year  8807 non-null   int64

 8   rating        8803 non-null   object

 9   duration      8804 non-null   object

 10  listed_in     8807 non-null   object

 11  description   8807 non-null   object

dtypes: int64(1), object(11)

memory usage: 894.5+ KB

In [263]:

netflix[netflix["director"].isna()]

Out[263]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

1

s2

TV Show

Blood & Water

NaN

Ama Qamata, Khosi Ngema, Gail Mabalane, Thaban...

South Africa

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, TV Dramas, TV Mysteries

After crossing paths at a party, a Cape Town t...

3

s4

TV Show

Jailbirds New Orleans

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Docuseries, Reality TV

Feuds, flirtations and toilet talk go down amo...

4

s5

TV Show

Kota Factory

NaN

Mayur More, Jitendra Kumar, Ranjan Raj, Alam K...

India

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, Romantic TV Shows, TV ...

In a city of coaching centers known to train I...

10

s11

TV Show

Vendetta: Truth, Lies and The Mafia

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Crime TV Shows, Docuseries, International TV S...

Sicily boasts a bold "Anti-Mafia" coalition. B...

14

s15

TV Show

Crime Stories: India Detectives

NaN

NaN

NaN

September 22, 2021

2021

TV-MA

1 Season

British TV Shows, Crime TV Shows, Docuseries

Cameras following Bengaluru police on the job ...

...

...

...

...

...

...

...

...

...

...

...

...

...

8795

s8796

TV Show

Yu-Gi-Oh! Arc-V

NaN

Mike Liscio, Emily Bauer, Billy Bob Thompson, ...

Japan, Canada

May 1, 2018

2015

TV-Y7

2 Seasons

Anime Series, Kids' TV

Now that he's discovered the Pendulum Summonin...

8796

s8797

TV Show

Yunus Emre

NaN

Gökhan Atalay, Payidar Tüfekçioglu, Baran Akbu...

Turkey

January 17, 2017

2016

TV-PG

2 Seasons

International TV Shows, TV Dramas

During the Mongol invasions, Yunus Emre leaves...

8797

s8798

TV Show

Zak Storm

NaN

Michael Johnston, Jessica Gee-George, Christin...

United States, France, South Korea, Indonesia

September 13, 2018

2016

TV-Y7

3 Seasons

Kids' TV

Teen surfer Zak Storm is mysteriously transpor...

8800

s8801

TV Show

Zindagi Gulzar Hai

NaN

Sanam Saeed, Fawad Khan, Ayesha Omer, Mehreen ...

Pakistan

December 15, 2016

2012

TV-PG

1 Season

International TV Shows, Romantic TV Shows, TV ...

Strong-willed, middle-class Kashaf and carefre...

8803

s8804

TV Show

Zombie Dumb

NaN

NaN

NaN

July 1, 2019

2018

TV-Y7

2 Seasons

Kids' TV, Korean TV Shows, TV Comedies

While living alone in a spooky town, a young g...

2634 rows × 12 columns

In [264]:

netflix[netflix["director"].isna() & netflix["cast"].isna()]

Out[264]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

3

s4

TV Show

Jailbirds New Orleans

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Docuseries, Reality TV

Feuds, flirtations and toilet talk go down amo...

10

s11

TV Show

Vendetta: Truth, Lies and The Mafia

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Crime TV Shows, Docuseries, International TV S...

Sicily boasts a bold "Anti-Mafia" coalition. B...

14

s15

TV Show

Crime Stories: India Detectives

NaN

NaN

NaN

September 22, 2021

2021

TV-MA

1 Season

British TV Shows, Crime TV Shows, Docuseries

Cameras following Bengaluru police on the job ...

66

s67

TV Show

Raja Rasoi Aur Anya Kahaniyan

NaN

NaN

India

September 15, 2021

2014

TV-G

1 Season

Docuseries, International TV Shows

Explore the history and flavors of regional In...

69

s70

TV Show

Stories by Rabindranath Tagore

NaN

NaN

India

September 15, 2021

2015

TV-PG

1 Season

International TV Shows, TV Dramas

The writings of Nobel Prize winner Rabindranat...

...

...

...

...

...

...

...

...

...

...

...

...

...

8605

s8606

TV Show

Top Grier

NaN

NaN

United States

December 31, 2018

2018

TV-MA

3 Seasons

Reality TV

Social media star Hayes Grier returns to North...

8609

s8610

TV Show

Towies

NaN

NaN

NaN

December 27, 2017

2016

TV-MA

1 Season

International TV Shows, Reality TV

Australia's toughest tow truck operators work ...

8700

s8701

TV Show

Wartime Portraits

NaN

NaN

Poland

September 15, 2016

2014

TV-MA

1 Season

Docuseries, International TV Shows

Part live-action and part animation, this visu...

8755

s8756

TV Show

Women Behind Bars

NaN

NaN

United States

November 1, 2016

2010

TV-14

3 Seasons

Crime TV Shows, Docuseries

This reality series recounts true stories of w...

8803

s8804

TV Show

Zombie Dumb

NaN

NaN

NaN

July 1, 2019

2018

TV-Y7

2 Seasons

Kids' TV, Korean TV Shows, TV Comedies

While living alone in a spooky town, a young g...

352 rows × 12 columns

In [267]:

netflix[~netflix.director.notna()]

Out[267]:

 

show_id

type

title

director

cast

country

date_added

release_year

rating

duration

listed_in

description

1

s2

TV Show

Blood & Water

NaN

Ama Qamata, Khosi Ngema, Gail Mabalane, Thaban...

South Africa

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, TV Dramas, TV Mysteries

After crossing paths at a party, a Cape Town t...

3

s4

TV Show

Jailbirds New Orleans

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Docuseries, Reality TV

Feuds, flirtations and toilet talk go down amo...

4

s5

TV Show

Kota Factory

NaN

Mayur More, Jitendra Kumar, Ranjan Raj, Alam K...

India

September 24, 2021

2021

TV-MA

2 Seasons

International TV Shows, Romantic TV Shows, TV ...

In a city of coaching centers known to train I...

10

s11

TV Show

Vendetta: Truth, Lies and The Mafia

NaN

NaN

NaN

September 24, 2021

2021

TV-MA

1 Season

Crime TV Shows, Docuseries, International TV S...

Sicily boasts a bold "Anti-Mafia" coalition. B...

14

s15

TV Show

Crime Stories: India Detectives

NaN

NaN

NaN

September 22, 2021

2021

TV-MA

1 Season

British TV Shows, Crime TV Shows, Docuseries

Cameras following Bengaluru police on the job ...

...

...

...

...

...

...

...

...

...

...

...

...

...

8795

s8796

TV Show

Yu-Gi-Oh! Arc-V

NaN

Mike Liscio, Emily Bauer, Billy Bob Thompson, ...

Japan, Canada

May 1, 2018

2015

TV-Y7

2 Seasons

Anime Series, Kids' TV

Now that he's discovered the Pendulum Summonin...

8796

s8797

TV Show

Yunus Emre

NaN

Gökhan Atalay, Payidar Tüfekçioglu, Baran Akbu...

Turkey

January 17, 2017

2016

TV-PG

2 Seasons

International TV Shows, TV Dramas

During the Mongol invasions, Yunus Emre leaves...

8797

s8798

TV Show

Zak Storm

NaN

Michael Johnston, Jessica Gee-George, Christin...

United States, France, South Korea, Indonesia

September 13, 2018

2016

TV-Y7

3 Seasons

Kids' TV

Teen surfer Zak Storm is mysteriously transpor...

8800

s8801

TV Show

Zindagi Gulzar Hai

NaN

Sanam Saeed, Fawad Khan, Ayesha Omer, Mehreen ...

Pakistan

December 15, 2016

2012

TV-PG

1 Season

International TV Shows, Romantic TV Shows, TV ...

Strong-willed, middle-class Kashaf and carefre...

8803

s8804

TV Show

Zombie Dumb

NaN

NaN

NaN

July 1, 2019

2018

TV-Y7

2 Seasons

Kids' TV, Korean TV Shows, TV Comedies

While living alone in a spooky town, a young g...

2634 rows × 12 columns

In [293]:

titanic[titanic["sex"] == "female"].survived.value_counts()

Out[293]:

1    339

0    127

Name: survived, dtype: int64

In [294]:

titanic[titanic["sex"] == "male"].survived.value_counts()

Out[294]:

0    682

1    161

Name: survived, dtype: int64

In [299]:

women = titanic["sex"] == "female"titanic[women].survived.value_counts().plot(kind="pie")

Out[299]:

<AxesSubplot:ylabel='survived'>

 

In [300]:

titanic[~women].survived.value_counts().plot(kind="pie")

Out[300]:

<AxesSubplot:ylabel='survived'>

 

In [305]:

houses[houses["price"] > 3000000].zipcode.value_counts().plot(kind="bar")

Out[305]:

<AxesSubplot:>

 

In [307]:

houses.zipcode.value_counts().head(10).plot(kind="bar")

Out[307]:

<AxesSubplot:>